<template>
  <div class="about">
    <i class="ab-icon2 iconfont icon-shangyiyehoutuifanhui-yuankuang"></i>
    <div class="ab-icon" :style="isOpacity">
      <i class="ab-icon3 iconfont icon-shangyiyehoutuifanhui-yuankuang"></i>
      <h3>{{title}}</h3>
    </div>
    <img :src="imgUrl" alt="">
    <!-- 注意：这里图片需要这样渲染数据，:src="" -->
    <p>{{summary}}</p>
  </div>
</template>
<script>
import axios from "axios-jsonp-pro";
export default {
  name:'About',
  data(){
    return {
      imgUrl:"",
      title:"",
      summary:"",
      isOpacity:{
        opacity:0
      }
    }
  },
  mounted(){
    var id = this.$route.params.id;
    // console.log(id);
    // var url = "https://api.douban.com/v2/movie/subject/";
    var url = "https://douban.uieee.com/v2/movie/subject/";
    // var url = "http://t.yushu.im/v2/movie/subject/";
    axios.jsonp(url+id).then(res=>{
      this.imgUrl = res.images.small;
      this.title = res.title;
      this.summary = res.summary;
    })
    var self = this;
    window.addEventListener('scroll',this.handleScroll)
  },
  methods:{
    handleScroll(){
      var top = document.documentElement.scrollTop || document.body.scrollTop;
      var opacity = top/200;
      if(opacity>=1){
        opacity = 1 ;
      }
      this.isOpacity.opacity = opacity ;
      console.log(1);
    }
  },
  destroyed(){
    window.removeEventListener("scroll",this.handleScroll);
  }
}
</script>
<style lang="scss" scoped>
.about{
  text-align: center;
  width: 619px;
}
.about p{
  width: 61%;
  margin-left: auto;
  margin-right: auto;
  text-indent: 34px;
}
.about img{
  margin-top: 46px;
}
.ab-icon{
    display: flex;
    justify-content: center;
    position: fixed;
    align-items: center;
    color: #fff;
    top: 0;
    width: 61%;
    height: 50px;
    background: skyblue;
    left: 130px;
}
.ab-icon2{
  font-size: 26px;
  position: absolute;
  left: 129px;
}
.ab-icon3{
  font-size: 26px;
  position: absolute; 
  left: 0;
  color: #fff;
}
</style>

